<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px"  class="custom-scrollbar">
      <!-- ------起始---------->
      <el-menu class="el-menu-vertical-demo" router> 
        <div class="title">通用后台管理系统</div>       
        <el-menu-item index="home">
          <el-icon><House /></el-icon>
          <span>首页</span>
        </el-menu-item>
        <el-menu-item index="2">
          <el-icon><Document /></el-icon>
          <span>系统概览</span>
        </el-menu-item>
       <!-- -------用户管理子菜单起始------ -->
        <el-sub-menu index="3">
          <template #title>
            <el-icon><User /></el-icon>
            <span>用户管理</span>
          </template>
          <el-menu-item-group title="管理员管理">
            <el-menu-item index="3-1">产品管理员</el-menu-item>
            <el-menu-item index="3-2">用户管理员</el-menu-item>
            <el-menu-item index="3-2">消息管理员</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group title="员工管理">
            <el-menu-item index="3-4">用户列表</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu>
     <!-- -------用户管理子菜单结束------ -->

       <!-- -------产品管理子菜单起始------ -->
        <el-sub-menu index="4">
          <template #title>
            <el-icon><TakeawayBox /></el-icon>
            <span>产品管理</span>
          </template>
          <el-menu-item-group title="入库管理">
            <el-menu-item index="4-1">产品列表</el-menu-item>
           
          </el-menu-item-group>
          <el-menu-item-group title="出库管理">
            <el-menu-item index="4-2">出库列表</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu>
     <!-- -------产品管理子菜单结束------ -->

       <!-- -------消息管理子菜单起始------ -->
        <el-sub-menu index="5">
          <template #title>
            <el-icon><ChatSquare /></el-icon>
            <span>消息管理</span>
          </template>
          <el-menu-item-group title="消息管理">
            <el-menu-item index="5-1">消息列表</el-menu-item>
           
          </el-menu-item-group>
          <el-menu-item-group title="回收站">
            <el-menu-item index="5-2">回收站</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu>
     <!-- -------消息管理子菜单结束------ -->
        <el-menu-item index="6">
          <el-icon><icon-menu /></el-icon>
          <span>合同管理</span>
        </el-menu-item>
        <el-menu-item index="7">       
          <el-icon><icon-menu /></el-icon>
          <span>操作日志</span>
        </el-menu-item>
        <el-menu-item index="8">
          <el-icon><icon-menu /></el-icon>
          <span>登录日志</span>
        </el-menu-item>
        <el-menu-item index="9">
          <el-icon><Tools /></el-icon>
          <span>系统设置</span>
        </el-menu-item>
      </el-menu>
      <!-- -----------结尾---------------- -->
      </el-aside>
      <el-container>
        <el-header>
          <span class="header-left-content">尊敬的 李青 欢迎您登录本系统</span>
          <div class="header-right-content">
            <el-icon :size="20"><Message/></el-icon>
            <el-avatar :size="24" :src="circleUrl" />
      <!-- ------下拉菜单起始------------------ -->
            <el-dropdown>
              <span class="el-dropdown-link">
                设置
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item>设置账号</el-dropdown-item>
                  <el-dropdown-item>更改头像</el-dropdown-item>
                  <el-dropdown-item @click="goLogin">退出登录</el-dropdown-item>
                 
                </el-dropdown-menu>
              </template>
            </el-dropdown>
      <!-- ------下拉菜单结束-------------------- -->
          </div>
        </el-header>
        <el-main>
            <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
   import {Menu as IconMenu} from '@element-plus/icons-vue'
   import {useRouter}from 'vue-router'
   import { reactive, toRefs,ref } from 'vue'

   const router=useRouter()

const state = reactive({
  circleUrl:
    'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
  
})

const { circleUrl } = toRefs(state)

const goLogin=()=>{
   router.push('/login')
}
</script>

<style lang="scss" scoped>
  .el-aside{
    height: 100vh;
    width: 200px;
    background:#2b303b;
    // 隐藏横轴滚动条
    overflow-x:hidden;
    // overflow-y:hidden;

    .el-menu{
      background:#2b303b;
      width: 200px;
      height: 100vh;
      border-right:0px;
    }

    .title{
      padding: 20px;
      display: flex;
      justify-content: center;
      color: #fff;
      background:#2b303b;
    }
    .el-menu-item{
      color:#fff;
    }   
  }

 .el-header{
    display: flex;
    background:#262f3e;
    color: #c1c6c8;
    align-items: center;
    justify-content: space-between;
    // 欢迎您
    .header-left-content{
      font-size: 14px;
    }

    .header-right-content{
      width: 160px;
      display: flex;
      justify-content: space-around;
    }
 }

  //无子菜单的
  .el-menu-item:hover{
    background:#006eff;
  }
  // 有子菜单的
  :deep(.el-sub-menu__title:hover){
    background:#006eff;
  }

  .custom-scrollbar::-webkit-scrollbar {
  width: 4px; /* 控制滚动条的宽度 */
}
 :deep(.el-sub-menu__title){
      color:#fff;
    }
 :deep(.el-menu--inline){
      // color:#fff;
      background:#2b303b;
 }
</style>
